<?php
/*
 * Copyright (c) 2022.  Liuhongbin All rights reserved.
 * @domain http://dkyx.cc
 * @author liuhongbin <514660094@qq.com>
 */

/**
 * @Author: liuhongbin
 * @Email: 514660094@qq.com
 * @Date: 2019-02-12 16:15:10
 * @Description:
 * @LastEditors: liuhongbin
 * @LastEditTime: xxx
 */

namespace hiduoke\services\formBuilder\form;


use FormBuilder\Driver\FormComponent;
use FormBuilder\Factory\Elm;
use FormBuilder\UI\Elm\Components\Select;

class DkSelect extends FormComponent
{
    protected $selectComponent = true;

    protected $defaultProps = [
        'multiple' => false
    ];

    protected static $propsRule = [
        'multiple'           => 'bool',
        'disabled'           => 'bool',
        'valueKey'           => 'string',
        'size'               => 'string',
        'clearable'          => 'bool',
        'collapseTags'       => 'bool',
        'multipleLimit'      => 'float',
        'name'               => 'string',
        'autocomplete'       => 'string',
        'placeholder'        => 'string',
        'filterable'         => 'bool',
        'allowCreate'        => 'bool',
        'remote'             => 'bool',
        'remoteUrl'          => 'string',
        'loading'            => 'bool',
        'loadingText'        => 'string',
        'noMatchText'        => 'string',
        'noDataText'         => 'string',
        'popperClass'        => 'string',
        'reserveKeyword'     => 'bool',
        'defaultFirstOption' => 'bool',
        'popperAppendToBody' => 'bool',
        'automaticDropdown'  => 'bool',
    ];

    public function createValidate()
    {
        if ($this->props['multiple'] == true)
            return Elm::validateArr();
        else
            return Elm::validateStr();
    }

    public function remoteUrl($url)
    {
        $this->props['remoteUrl'] = $url;
        return $this;
    }
}
